/**
 * Copyright (C) 2013 SHANGHAI VOLKSWAGEN, All rights reserved.
 * License version 1.0, a copy of which has been included with this.
 *
 * @File name：com.bwie.auth.controller.AuthController
 * @Create on：2024/3/22
 * @Author：liuchang
 */
package com.bwie.auth.controller;

import com.bwie.auth.service.AuthService;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.LoginRequest;
import com.bwie.common.domain.response.LoginResponse;
import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>ClassName：AuthController</p >
 * <p>Description：</p >
 * <p>Author：liuchang</p >
 * <p>Date：2024/3/22</p >
 */
@RestController
public class AuthController {
    @Autowired
    private AuthService authService;
    /*
     *
     * 手机号/密码登录
     * */
    @PostMapping("/login")
    public Result login(@RequestBody@Validated LoginRequest loginRequest){
        LoginResponse loginResponse=authService.login(loginRequest);
        return Result.success(loginResponse);
    }
    /*
     *
     * 获取登陆人信息
     * */
    @PostMapping("/userInfo")
    public Result<User> userInfo(){
        User user=authService.userInfo();
        return Result.success(user);
    }
    /*
     *
     * 注销
     * */
    @PostMapping("/logOut")
    public Result logOut(){
        return authService.logOut();
    }
}
